package ee.serge;

import java.util.List;

public class KnapsackState implements Comparable<KnapsackState> {

   private List<KnapsackObject> objectsLeft;
   private List<KnapsackObject> objectsTaken;
   private int weight;
   private int price;
   private float greedyPrice;
   
   public KnapsackState(List<KnapsackObject> objectsLeft, List<KnapsackObject> objectsTaken, int weight, int price) {
      this.objectsLeft = objectsLeft;
      this.objectsTaken = objectsTaken;
      this.weight = weight;
      this.price = price;
   }

   public KnapsackState(List<KnapsackObject> objectsLeft, List<KnapsackObject> objectsTaken, int weight, int price, float greedyPrice) {
      this.objectsLeft = objectsLeft;
      this.objectsTaken = objectsTaken;
      this.weight = weight;
      this.price = price;
      this.greedyPrice = greedyPrice;
   }
   
   public List<KnapsackObject> getObjectsLeft() {
      return objectsLeft;
   }

   public int getWeight() {
      return weight;
   }

   public int getPrice() {
      return price;
   }
   
   public float getGreedyPrice() {
      return greedyPrice;
   }

   @Override
   public int compareTo(KnapsackState o) {
      if (greedyPrice < o.getGreedyPrice()) return 1;
      else if (greedyPrice > o.getGreedyPrice()) return -1;
      return 0;
   }

   public void setObjects(List<KnapsackObject> objects) {
      this.objectsLeft = objects;
   }

   public void setWeight(int weight) {
      this.weight = weight;
   }

   public void setPrice(int price) {
      this.price = price;
   }

   public void setGreedyPrice(float greedyPrice) {
      this.greedyPrice = greedyPrice;
   }

   public List<KnapsackObject> getObjectsTaken() {
      return objectsTaken;
   }

   public void setObjectsTaken(List<KnapsackObject> objectsTaken) {
      this.objectsTaken = objectsTaken;
   }

   public void setObjectsLeft(List<KnapsackObject> objectsLeft) {
      this.objectsLeft = objectsLeft;
   }

   @Override
   public String toString() {
      final int maxLen = 1;
      return "KnapsackState [objectsLeft="
            + (objectsLeft)
            + ", objectsTaken="
            + (objectsTaken)
            + ", weight=" + weight + ", price=" + price + ", greedyPrice=" + greedyPrice + "]";
   }
   

}
